<?php
include("db_connect.php");
require_once("class/objName.php");
$obj = new objName();
$sql = "SELECT * FROM tblbrand ";
$result = mysql_query($sql)or die($sql);
$display2 = "";
	while($row = mysql_fetch_array($result)){
	
	
	$brandtitle = $row['brand'];
		
	if($obj->brandindb($brandtitle) == true){
		$brandtitle = $brandtitle;
	
	
	
		$display2 .= '<div id="boxal" >';
		$display2 .= '<h4 style="color:white">'.$brandtitle.'</h4>';
		$sql2 = mysql_query("SELECT * FROM tblswaping where display = '1' AND categories = 'Auto' AND brand = '$brandtitle' ORDER BY id DESC limit 6") or die(mysql_error());
		$display2 .= '<div id="boxal" >';
		if(mysql_num_rows($sql2)< 1){
			
			$display .= "";		
		}
		
		while($rows = mysql_fetch_array($sql2)){
			$img = array();
			$img = explode("+", $rows['filename']);
			
			
			if($brandtitle == $rows['brand']){
				
				$alt = 'Model: '.$rows['model']. '';
				
				$display2 .= '<div class="gallery_box">';
				$display2 .= '	<a href="images/vehicles/'.$img[0].'" rel="lightbox[portfolio]" ><img src="images/vehicles/'.$img[0].'" alt="'.$alt.'  " title="'.$alt.'" style="width:185px; height:100px; border:2px solid red;" class="image_frame"/></a>';
				$display2 .= '   </br> <a href="preview.php?from=index+&pageid='.$rows['id'].'" style="color:red;">'.$rows['name'].'</a>';
				$display2 .= '    <p>P '.$rows['price'].'</p>';
				$display2 .= '</div>';
			
			}
			
			
		}
		$display2 .= '</div>';
		$display2 .= ' </div>';
		
	
	
}
}
echo $display2;


?>




